home *** CD-ROM | disk | FTP | other *** search
/ Game Programming in C++ - Start to Finish / GameProgrammingS.iso / developer_install / CEGUISDK-0.4.1-VC6-Native.exe / {app} / include / elements / CEGUIButtonBase.h next >
Encoding:
C/C++ Source or Header  |  2005-06-04  |  10.0 KB  |  340 lines

  1. /************************************************************************
  2.     filename:     CEGUIButtonBase.h
  3.     created:    13/4/2004
  4.     author:        Paul D Turner
  5.     
  6.     purpose:    Interface to base class for ButtonBase widget
  7. *************************************************************************/
  8. /*************************************************************************
  9.     Crazy Eddie's GUI System (http://www.cegui.org.uk)
  10.     Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
  11.  
  12.     This library is free software; you can redistribute it and/or
  13.     modify it under the terms of the GNU Lesser General Public
  14.     License as published by the Free Software Foundation; either
  15.     version 2.1 of the License, or (at your option) any later version.
  16.  
  17.     This library is distributed in the hope that it will be useful,
  18.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  19.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  20.     Lesser General Public License for more details.
  21.  
  22.     You should have received a copy of the GNU Lesser General Public
  23.     License along with this library; if not, write to the Free Software
  24.     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  25. *************************************************************************/
  26. #ifndef _CEGUIButtonBase_h_
  27. #define _CEGUIButtonBase_h_
  28.  
  29. #include "CEGUIBase.h"
  30. #include "CEGUIWindow.h"
  31. #include "elements/CEGUIButtonBaseProperties.h"
  32.  
  33.  
  34. #if defined(_MSC_VER)
  35. #    pragma warning(push)
  36. #    pragma warning(disable : 4251)
  37. #endif
  38.  
  39.  
  40. // Start of CEGUI namespace section
  41. namespace CEGUI
  42. {
  43.  
  44. /*!
  45. \brief
  46.     Base class for all the 'button' type widgets (push button, radio button, check-box, etc)
  47. */
  48. class CEGUIEXPORT ButtonBase : public Window
  49. {
  50. public:
  51.     /*************************************************************************
  52.         Constants
  53.     *************************************************************************/
  54.     // default colours for text label rendering
  55.     static const colour        DefaultNormalLabelColour;        //!< Default colour used when rendering label text in normal state.
  56.     static const colour        DefaultHoverLabelColour;        //!< Default colour used when rendering label text in hover / highlight state.
  57.     static const colour        DefaultPushedLabelColour;        //!< Default colour used when rendering label text in pushed state.
  58.     static const colour        DefaultDisabledLabelColour;        //!< Default colour used when rendering label text in disabled state.
  59.  
  60.  
  61.     /*************************************************************************
  62.         Accessor type functions
  63.     *************************************************************************/
  64.     /*!
  65.     \brief
  66.         return true if user is hovering over this widget (or it's pushed and user is not over it for highlight)
  67.  
  68.     \return
  69.         true if the user is hovering or if the button is pushed and the mouse is not over the button.  Otherwise return false.
  70.     */
  71.     bool    isHovering(void) const            {return d_hovering;}
  72.  
  73.  
  74.     /*!
  75.     \brief
  76.         Return true if the button widget is in the pushed state.
  77.  
  78.     \return
  79.         true if the button-type widget is pushed, false if the widget is not pushed.
  80.     */
  81.     bool    isPushed(void) const            {return d_pushed;}
  82.  
  83.  
  84.     /*!
  85.     \brief
  86.         return text label colour used for normal rendering
  87.  
  88.     \return
  89.         colour value that is used for the label text when rendering in the normal state.
  90.     */
  91.     colour    getNormalTextColour(void) const            {return d_normalColour;}
  92.  
  93.  
  94.     /*!
  95.     \brief
  96.         return text label colour used for hover / highlight rendering
  97.  
  98.     \return
  99.         colour value that is used for the label text when rendering in the hover / highlighted states.
  100.     */
  101.     colour    getHoverTextColour(void) const            {return d_hoverColour;}
  102.  
  103.  
  104.     /*!
  105.     \brief
  106.         return text label colour used for pushed rendering
  107.  
  108.     \return
  109.         colour value that is used for the label text when rendering in the pushed state.
  110.     */
  111.     colour    getPushedTextColour(void) const            {return d_pushedColour;}
  112.  
  113.  
  114.     /*!
  115.     \brief
  116.         return text label colour used for disabled rendering
  117.  
  118.     \return
  119.         colour value that is used for the label text when rendering in the disabled state.
  120.     */
  121.     colour    getDisabledTextColour(void) const        {return d_disabledColour;}
  122.  
  123.     /*************************************************************************
  124.         Manipulators
  125.     *************************************************************************/
  126.     /*!
  127.     \brief
  128.         Set the colour to use for the label text when rendering in the normal state.
  129.  
  130.     \param colour
  131.         colour value specifying the colour to be used.
  132.  
  133.     \return
  134.         Nothing.
  135.     */
  136.     void    setNormalTextColour(const colour& colour);
  137.  
  138.  
  139.     /*!
  140.     \brief
  141.         Set the colour to use for the label text when rendering in the hover / highlighted states.
  142.  
  143.     \param colour
  144.         colour value specifying the colour to be used.
  145.  
  146.     \return
  147.         Nothing.
  148.     */
  149.     void    setHoverTextColour(const colour& colour);
  150.  
  151.  
  152.     /*!
  153.     \brief
  154.         Set the colour to use for the label text when rendering in the pushed state.
  155.  
  156.     \param colour
  157.         colour value specifying the colour to be used.
  158.  
  159.     \return
  160.         Nothing.
  161.     */
  162.     void    setPushedTextColour(const colour& colour);
  163.  
  164.  
  165.     /*!
  166.     \brief
  167.         Set the colour to use for the label text when rendering in the disabled state.
  168.  
  169.     \param colour
  170.         colour value specifying the colour to be used.
  171.  
  172.     \return
  173.         Nothing.
  174.     */
  175.     void    setDisabledTextColour(const colour& colour);
  176.  
  177.     /*************************************************************************
  178.         Construction and Destruction
  179.     *************************************************************************/
  180.     /*!
  181.     \brief
  182.         Constructor for ButtonBase objects
  183.     */
  184.     ButtonBase(const String& type, const String& name);
  185.  
  186.  
  187.     /*!
  188.     \brief
  189.         Destructor for ButtonBase objects
  190.     */
  191.     virtual ~ButtonBase(void);
  192.  
  193.  
  194. protected:
  195.     /*************************************************************************
  196.         Overridden event handlers
  197.     *************************************************************************/
  198.     virtual void    onMouseMove(MouseEventArgs& e);
  199.     virtual void    onMouseButtonDown(MouseEventArgs& e);
  200.     virtual void    onMouseButtonUp(MouseEventArgs& e);
  201.     virtual void    onCaptureLost(WindowEventArgs& e);
  202.     virtual void    onMouseLeaves(MouseEventArgs& e);
  203.  
  204.  
  205.     /*************************************************************************
  206.         Implementation Functions
  207.     *************************************************************************/
  208.     /*!
  209.     \brief
  210.         Update the internal state of the widget with the mouse at the given position.
  211.  
  212.     \param mouse_pos
  213.         Point object describing, in screen pixel co-ordinates, the location of the mouse cursor.
  214.  
  215.     \return
  216.         Nothing
  217.     */
  218.     void    updateInternalState(const Point& mouse_pos);
  219.  
  220.  
  221.     /*!
  222.     \brief
  223.         Return whether this window was inherited from the given class name at some point in the inheritance heirarchy.
  224.  
  225.     \param class_name
  226.         The class name that is to be checked.
  227.  
  228.     \return
  229.         true if this window was inherited from \a class_name. false if not.
  230.     */
  231.     virtual bool    testClassName_impl(const String& class_name) const
  232.     {
  233.         if (class_name==(const utf8*)"ButtonBase")    return true;
  234.         return Window::testClassName_impl(class_name);
  235.     }
  236.  
  237.  
  238.     /*************************************************************************
  239.         Implementation Rendering Functions
  240.     *************************************************************************/
  241.     /*!
  242.     \brief
  243.         Perform the rendering for this widget.
  244.  
  245.     \param z
  246.         float value specifying the base Z co-ordinate that should be used when rendering
  247.  
  248.     \return
  249.         Nothing
  250.     */
  251.     virtual    void    drawSelf(float z);
  252.  
  253.  
  254.     /*!
  255.     \brief
  256.         Render the button-type widget in it's 'normal' state
  257.  
  258.     \param z
  259.         float value specifying the base Z co-ordinate that should be used when rendering
  260.  
  261.     \return
  262.         Nothing
  263.     */
  264.     virtual void    drawNormal(float z)        = 0;
  265.  
  266.  
  267.     /*!
  268.     \brief
  269.         Render the button-type widget in it's 'hover' (highlighted) state
  270.  
  271.     \param z
  272.         float value specifying the base Z co-ordinate that should be used when rendering
  273.  
  274.     \return
  275.         Nothing
  276.     */
  277.     virtual void    drawHover(float z)            {drawNormal(z);}
  278.  
  279.  
  280.     /*!
  281.     \brief
  282.         Render the button-type widget in it's 'pushed' state
  283.  
  284.     \param z
  285.         float value specifying the base Z co-ordinate that should be used when rendering
  286.  
  287.     \return
  288.         Nothing
  289.     */
  290.     virtual void    drawPushed(float z)        {drawNormal(z);}
  291.  
  292.  
  293.     /*!
  294.     \brief
  295.         Render the button-type widget in it's 'disabled' state
  296.  
  297.     \param z
  298.         float value specifying the base Z co-ordinate that should be used when rendering
  299.  
  300.     \return
  301.         Nothing
  302.     */
  303.     virtual void    drawDisabled(float z)        {drawNormal(z);}
  304.  
  305.  
  306.     /*************************************************************************
  307.         Implementation Data
  308.     *************************************************************************/
  309.     bool    d_pushed;            //!< true when widget is pushed
  310.     bool    d_hovering;            //!< true when the button is in 'hover' state and requires the hover rendering.
  311.  
  312.     // common rendering setting data
  313.     colour    d_normalColour;                    //!< Colour used for label text when rendering in normal state
  314.     colour    d_hoverColour;                    //!< Colour used for label text when rendering in highlighted state
  315.     colour    d_pushedColour;                    //!< Colour used for label text when rendering in pushed state
  316.     colour    d_disabledColour;                //!< Colour used for label text when rendering in disabled state
  317.  
  318. private:
  319.     /*************************************************************************
  320.         Static Properties for this class
  321.     *************************************************************************/
  322.     static ButtonBaseProperties::NormalTextColour    d_normalTextColourProperty;
  323.     static ButtonBaseProperties::HoverTextColour    d_hoverTextColourProperty;
  324.     static ButtonBaseProperties::PushedTextColour    d_pushedTextColourProperty;
  325.     static ButtonBaseProperties::DisabledTextColour    d_disabledTextColourProperty;
  326.  
  327.     /*************************************************************************
  328.         Private methods
  329.     *************************************************************************/
  330.     void    addButtonBaseProperties(void);
  331. };
  332.  
  333. } // End of  CEGUI namespace section
  334.  
  335. #if defined(_MSC_VER)
  336. #    pragma warning(pop)
  337. #endif
  338.  
  339. #endif    // end of guard _CEGUIButtonBase_h_
  340.